<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>


<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>角色列表</title>
    <link rel="stylesheet" href="../styles/style.css" type="text/css"/>

    <script>
        window.onload = function(){
            document.getElementById("btn1").onclick= function(){
                var checkboxObj = document.getElementsByClassName("cks");
                var cks=[];
                for(var i=0;i<checkboxObj.length;i++){
                    if(checkboxObj[i].checked == true){
                        cks.push(checkboxObj[i].value);
                    }
                }
                if(confirm("确定要删除吗")){
                    location.href = "${pageContext.request.contextPath}/delRolesByids?ids="+cks;
                }
            }
        }
    </script>
</head>


<body>
    <div id="main_body">
        <ul class="main_top">
            <li class="main_top_left left">
                查询
                <BR>
            </li>
            <li class="main_top_right right">
            </li>
        </ul>
        <div class="main_content_rightbg">
            <div class="main_content_leftbg">
                <form name="form1" method="post" action="${pageContext.request.contextPath}/queryRole">
                <table width="80%" border="0" align=center cellpadding="2"
                       cellspacing="1" bgcolor="#FFFFFF" class="border">
                    <tr>
                        <td width="9%" align="center" class="tdbg">
                            <strong>角色编号</strong>
                        </td>
                        <td width="13%" align="left" class="tdbg">
                            <input type="text" name="id"/>
                        </td>
                        <td width="9%" align="center" class="tdbg">
                            <strong>角色名称</strong>
                        </td>
                        <td width="21%" align="left" class="tdbg">
                            <input name="rolename">
                        </td>
                        <td align="left" nowrap class="tdbg">
                            <button type="submit" >查询</button>
                            <input type="button" onclick=location.href="${pageContext.request.contextPath}/toaddRole" value="添加">
                        </td>
                    </tr>
                </table>
                </form>
            </div>
        </div>

        <ul class="main_end">
            <li class="main_end_left left"></li>
            <li class="main_end_right right"></li>
        </ul>
        <!--******************************************** -->
        <ul class="main_top">
            <li class="main_top_left left">
                角色信息列表
                <BR>
            </li>
            <li class="main_top_right right">
            </li>
        </ul>
        <div class="main_content_rightbg">
            <div class="main_content_leftbg">

                <table width="80%" border="0" align=center cellpadding="2"
                       cellspacing="1" bgcolor="#FFFFFF" class="border">
                    <tr>
                        <td width="5%" align="center" nowrap class="tdbg">
                            <strong>选择</strong>
                        </td>
                        <td width="23%" align="center" class="tdbg">
                            <strong>角色编号</strong>
                        </td>
                        <td width="19%" align="center" class="tdbg">
                            <strong>角色名称</strong>
                        </td>

                        <td width="35%" align="center" nowrap class="tdbg">
                            <strong>操作</strong>
                        </td>
                    </tr>

                    <c:forEach items="${roleInfo.list}" var="r">
                        <tr>
                            <td align="left" class="tdbg">
                                <input type="checkbox" value="${r.id}" class="cks">
                            </td>
                            <td align="center" class="tdbg">
                                    ${r.id}
                            </td>
                            <td align="center" class="tdbg">
                                    ${r.rolename}
                            </td>
                            <td align="center" class="tdbg">
                                <a href="${pageContext.request.contextPath}/delRoleById?id=${r.id}" id="sc">删除</a>
                                <a href="${pageContext.request.contextPath}/findRoleById?id=${r.id}">修改</a>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
                <table width="80%" border="0" align=center cellpadding="0"
                       cellspacing="0" bgcolor="#FFFFFF">

                    <tr>
                        <td width="10%" align="left" class="tdbg">
                            <INPUT id="chkAll" type="checkbox" value="checkbox"
                                   name="chkAll">
                            全选
                        </td>
                        <td width="90%" align="left" class="tdbg">
                            <STRONG>操作：</STRONG>
                            <button id="btn1">删除选定</button>
                        </td>
                    </tr>

                </table>
                <table width="80%" border="0" align=center cellpadding="2"
                       cellspacing="0" bgcolor="#FFFFFF" class="border">
                    <tr>
                        <td width="14%" height="40" align="left" class="tdbg">
                            &nbsp;
                        </td>
                        <td width="86%" align="left" class="tdbg">

                        </td>
                    </tr>
                </table>
                <table width="80%" border="0" align=center cellpadding="2"
                       cellspacing="0" bgcolor="#FFFFFF" class="border">
                    <tr>
                        <td height="40" align="center" class="tdbg">
                            <p>
                                当前第${roleInfo.pageNum}页，总${roleInfo.pages}页,总${roleInfo.total}条记录
                            </p>
                            <a href="jueseguanli?pageNo=${roleInfo.navigateFirstPage}">首页</a>
                            <c:if test="${roleInfo.hasPreviousPage }">
                                <a href="jueseguanli?pageNo=${roleInfo.pageNum-1}">上一页</a>
                            </c:if>
                            <c:forEach begin="1" end="${roleInfo.pages}" var="i">
                                <a href="jueseguanli?pageNo=${i}">[${i}]</a>
                            </c:forEach>
                            <c:if test="${roleInfo.hasNextPage }">
                                <a href="jueseguanli?pageNo=${roleInfo.pageNum+1}">下一页</a>
                            </c:if>

                            <a href="${pageContext.request.contextPath}/jueseguanli?pageNo=${roleInfo.navigateLastPage}">尾页</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <ul class="main_end">
            <li class="main_end_left left"></li>
            <li class="main_end_right right"></li>
        </ul>
    </div>

</body>
</html>